<?php
declare (strict_types=1);

namespace app\backend\validate;

use think\Validate;

class PermissionValidate extends Validate
{
    /**
     * 定义验证规则
     * 格式：'字段名' =>  ['规则1','规则2'...]
     *
     * @var array
     */
    protected $rule = [
        'id' => 'require',
        'title' => 'require|unique:backend_permission|max:25',
        'action' => 'require',
        'component' => 'require'
    ];

    /**
     * 定义错误信息
     * 格式：'字段名.规则名' =>  '错误信息'
     *
     * @var array
     */
    protected $message = [
        'id.require' => 'id不能为空',
        'title.require' => '请输入节点名称',
        'title.unique' => '节点名称已存在',
        'title.max' => '节点名称不能超过25位！',
        'action.require' => '请输入路由',
        'component.require' => '请输入组件路径',

    ];
    /**
     * 验证场景
     */
    protected $scene = [
        'save' => ['title', 'action','component'],
        'update' => ['id', 'title', 'action','component']
    ];
}
